package com.android.thought.badboys.Info;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;

public class SelectionPhoneInfo implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private HashMap<String, PhoneInfo> mGroupMap;
	
	public SelectionPhoneInfo() {
		this.mGroupMap = new HashMap<String, PhoneInfo>(100);
	}
	
	public ArrayList<PhoneInfo> getList() { 
		Set<String> set = mGroupMap.keySet();
		ArrayList<PhoneInfo> list = new ArrayList<PhoneInfo>();
		
		for (String key : set) {
			list.add(mGroupMap.get(key));
		}
		
		return list;
	}
	
	public void addPhoneInfo(PhoneInfo info) { 
		if ( this.mGroupMap == null ) 
			this.mGroupMap = new HashMap<String, PhoneInfo>(100);
		
		if ( !this.mGroupMap.containsKey(info.getPhoneNumber() ) ) { 
			this.mGroupMap.put(info.getPhoneNumber(), info);
		}
	}
	
	public void removePhoneInfo(PhoneInfo info) { 
		if ( this.mGroupMap == null )
			return;
		
		if ( this.mGroupMap.containsKey(info.getPhoneNumber() ) ) { 
			this.mGroupMap.remove(info.getPhoneNumber());
		}
	}
}
